import { Component, PropTypes } from 'labrador-immutable';
import immutable from 'seamless-immutable';
import { connect } from 'labrador-redux';
import { bindActionCreators } from 'redux';
import { createAction } from 'redux-actions';

const { any } = PropTypes;

class PostComment extends Component {
  static propTypes = {
    foo: any
  };

  static defaultProps = {
    foo: 'bar'
  };

  constructor(props) {
    super(props);
    this.state = immutable({});
  }

  children() {
    return {};
  }

  // onLoad() {
  // }

  onLoad(options) {
    this.setState({ id: options.id });
  }

  handlePostComment(e) {
    if (! e.detail.value.content) {
      wx.showToast({ title: '请输入评论内容～' });
      return;
    }
    
    // wx.showToast({ title: e.detail.formId });
    // return;

    this.props.commentArticle({ content: e.detail.value.content, id: this.state.id, form_id: e.detail.formId });
  }
}

// export default PostComment;

export default connect(
  (state)=>({}),
  (dispatch) => bindActionCreators({
    commentArticle: createAction('user/commentArticle', (params) => (params))
  }, dispatch)
)(PostComment);
